<?php
$title = 'Posagi';
require_once("includes/head.php"); if (!$_GET['ajax']) require_once("includes/head_start.php"); 

//Uwaga!!! Ilo?? pos?gów ($ilepos) musi by? liczb? parzyst?, jak równie? liczba kolumn ($ilekol)!!!
//$arrMon - tablica ta, zawiera nazwy pos?gów i powinna by? w tej samej kolejno?ci co zapytania w SQL ($ladder).
//          pytania powsta?y w tym przypadku najpierw dla lewej kolumny, a nast?pnie dla prawej
$limit = 6;	//ilo?? wy?wietlanych rekordów dla danej tebeli
$ilekol = 2;    //ilo?? kolumn na stronie (je?li chcesz jedn?, to usu? linie w kodzie ze znacznikiem ###)
$ilepos = 24;   //ilo?? tabel (pos?gów) w jednej kolumnie (je?li masz jedn? kolumn?, to usu? linie w kodzie ze znacznikiem ###)
$ladder = $db -> Execute("(SELECT user, level FROM players WHERE rank !='Admin'  ORDER BY level DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, strength FROM players WHERE rank !='Admin'  ORDER BY strength DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, inteli FROM players WHERE rank !='Admin'  ORDER BY inteli DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, szyb FROM players WHERE rank !='Admin'  ORDER BY szyb DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, unik FROM players WHERE rank !='Admin'  ORDER BY unik DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, leadership FROM players WHERE rank !='Admin'  ORDER BY leadership DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, atak FROM players WHERE rank !='Admin'  ORDER BY atak DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, wins FROM players WHERE rank !='Admin'  ORDER BY wins DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, ability FROM players WHERE rank !='Admin'  ORDER BY ability DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, breeding FROM players WHERE rank !='Admin'  ORDER BY breeding DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, mining FROM players WHERE rank !='Admin'  ORDER BY mining DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, platinum FROM players WHERE rank !='Admin'  ORDER BY platinum DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, credits FROM players WHERE rank !='Admin'  ORDER BY credits DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, agility FROM players WHERE rank !='Admin'  ORDER BY agility DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, wytrz FROM players WHERE rank !='Admin'  ORDER BY wytrz DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, wisdom FROM players WHERE rank !='Admin'  ORDER BY wisdom DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, shoot FROM players WHERE rank !='Admin'  ORDER BY shoot DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, magia FROM players WHERE rank !='Admin'  ORDER BY magia DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, losses FROM players WHERE rank !='Admin'  ORDER BY losses DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, fletcher FROM players WHERE rank !='Admin'  ORDER BY fletcher DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, herbalist FROM players WHERE rank !='Admin'  ORDER BY herbalist DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, lumberjack FROM players WHERE rank !='Admin'  ORDER BY lumberjack DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, alchemia FROM players WHERE rank !='Admin'  ORDER BY alchemia DESC LIMIT $limit)
			   UNION ALL
			  (SELECT id, user, bank FROM players WHERE rank !='Admin'  ORDER BY bank DESC LIMIT $limit)");

$arrMon = array("Poziom", "Siła", "Inteligencja", "Szybkość", "Uniki", "Przywództwo", "Walka bronią", "Zwycięstwa", "Kowalstwo", "Hodowla", "Górnictwo", "Mithril", "Złoto w sakiewce",
                "Zręczność", "Wytrzymałość", "Siła Woli", "Strzelectwo", "Walka czarami", "Porażki", "Stolarstwo", "Zielarstwo", "Drwalnictwo", "Alchemia", "Złoto w Banku");
$i = 0;
$j = 0;
echo "<table><tr>";  //###
while (!$ladder -> EOF)  {

	if (($i == 0) || ($i == $limit * ($ilepos / 2))) { echo "<td>"; }   //###
	if ($i == $limit * $j) {
		echo "<table><tr> <td width='80' align='center'><b><u>Imię</u></b></td> <td width='150' align='center'><b><u>".$arrMon[$j]."</u></b></td> </tr>";
	$j = $j + 1;
	}
        	echo "<tr><td>".$ladder -> fields['user']."</a> (".$ladder -> fields['id'].")</td> <td align='right'>".round($ladder -> fields['level'],3)."</td></tr>";
	if ($i == $limit * $j - 1) {
		echo "</table><br />";
	}
	if (($i == $limit * ($ilepos / 2) - 1) || ($i == $limit * ($ilepos / 2) * $ilekol - 1)) { echo "</td>"; }  //###
	
        $ladder -> MoveNext();
$i = ($i + 1);
}
$ladder -> Close();
echo "</tr></table>";  //###
if (!$_GET['ajax']) require_once("includes/foot.php");
?>